<?php
//This function checks username and password of users.
function validateUser($name, $pword){

    $fh = fopen('users.txt', 'r');

    //Loop thru the file and get a line
    while($line = fgets($fh)) {
    //process the line that has just been read
    //convert the line string into an array, using "|" as the delimiter
    $lineArray = explode("|", $line);
    //put each element of the array into another variable
    //and process username and password
    $username = trim($lineArray[0]);
    $password = trim($lineArray[1]);

        if(($name == $username) && ($pword == $password)){
        $_SESSION['username'] == $username;
        //username & password verified
        return TRUE;
        }
    }
fclose($fh);
}











?>